<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>循环遍历</title>
</head>
<body>
<div>
    <input type="text" id="d1" placeholder="学生姓名" v-model="name">
    <input type="text" id="d2" placeholder="班级" v-model="salary">
    <input type="text" id="d3" placeholder="学号" v-model="job">
    <input type="button" value="添加" @click="f()">
    <table border="1">
        <caption>员工列表</caption>
        <tr>
            <th>姓名</th>
            <th>工资</th>
            <th>工作</th>
        </tr>
        <tr v-for="hero in arr">
            <td>{{hero.name}}</td>
            <td>{{hero.salary}}</td>
            <td>{{hero.job}}</td>
        </tr>
    </table>
</div>
<!--引入vue-->
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            arr:[
                {name:"孙悟空",salary:"打野",job:"18888"},
                {name:"韩信",salary: "打野",job: "18888"},
                {name:"夏洛特",salary: "战士",job: "13888"},],
            name:"",
            salary:"",
            job:""
        },
        methods:{
            f(){

                let m = {name:v.name,salary:v.salary,job: v.job}
                v.arr.push(m);
            }
        }

    })
</script>

</body>
</html>
